package cn.juque.workflow.helper;

import cn.hutool.core.collection.CollUtil;
import cn.juque.common.base.BaseResponseDTO;
import cn.juque.common.utils.ValidatorUtil;
import cn.juque.systemservice.api.dto.employee.EmployeeInfoDetailDTO;
import cn.juque.systemservice.api.dto.employee.EmployeeInfoSearchByRoleDTO;
import cn.juque.systemservice.api.dto.employee.EmployeeInfoSearchByUserIdDTO;
import cn.juque.systemservice.api.provider.IEmployeeInfoProvider;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author juque
 * @version 1.0.0
 * <ul>
 *     <li>EmployeeInfoHelper</li>
 * </ul>
 * @date 2023-02-04 11:12:48
 **/
@Component("employeeInfoHelper")
public class EmployeeInfoHelper {

    @Resource
    private IEmployeeInfoProvider employeeInfoProvider;

    @Resource
    private ValidatorUtil validatorUtil;

    public List<EmployeeInfoDetailDTO> listEmployeeByRoleId(List<String> roleIdList) {
        EmployeeInfoSearchByRoleDTO searchByRoleDTO = new EmployeeInfoSearchByRoleDTO();
        searchByRoleDTO.setRoleIdList(roleIdList);
        BaseResponseDTO<List<EmployeeInfoDetailDTO>> responseDTO = this.employeeInfoProvider.getByRoleIdList(searchByRoleDTO);
        this.validatorUtil.successful(responseDTO);
        return responseDTO.getData();
    }

    public List<EmployeeInfoDetailDTO> listEmployeeByUserId(List<String> userIdList) {
        if(CollUtil.isEmpty(userIdList)) {
            return CollUtil.newArrayList();
        }
        EmployeeInfoSearchByUserIdDTO searchByUserIdDTO = new EmployeeInfoSearchByUserIdDTO();
        searchByUserIdDTO.setUserIdList(userIdList);
        BaseResponseDTO<List<EmployeeInfoDetailDTO>> responseDTO = this.employeeInfoProvider.getByUserId(searchByUserIdDTO);
        this.validatorUtil.successful(responseDTO);
        return responseDTO.getData();
    }
}
